package tree.easy;

import tree.TreeNode;

/**
 * 404. 左叶子之和
 */
public class sumOfLeftLeaves {
    public int sumOfLeftLeaves(TreeNode root) {
        if (root != null) {
            int leftLeft = sumOfLeftLeaves(root.left);
            int rightLeft = sumOfLeftLeaves(root.right);
            int res = 0;
            if (root.left != null) {
                if (root.left.left == null && root.left.right == null) {
                    res = root.left.val;
                    System.out.println(root.left.val);
                }
            }
            return leftLeft + rightLeft + res;
        }
        return 0;
    }
}
